import java.util.Comparator;
import java.util.TreeSet;
class Student{
    private String id;
    private String name;
    public Student(String id, String name) {
        this. id= id;
        this. name = name;
    }
    public String getId() {
        return id;
    }
    public String getName() {
        return name;
    }

    // 重写 toString() 方法
    public String toString(){
        return id + ":" + name;
    }
}
public class Example13 {
    public static void main(String[] args)
    {
        TreeSet ts = new TreeSet(new Comparator() {
            @Override
            public int compare(Object ol, Object o2){
                Student stul= (Student)ol;
                Student stu2= (Student)o2;
                if(!stul.getId().equals(stu2.getId())){
                    return stul.getId().compareTo(stu2.getId());
                }
                else
                    return stul.getName().compareTo(stu2.getName());
            }
        });
        ts.add(new Student("2", "Mary"));
        ts.add(new Student("1", "Jack"));
        ts.add(new Student("3", "Lisa"));
        ts.add(new Student("2", "Lily"));
        System.out.println(ts);
    }
}